package cate.game.play.skill.passive.talent;

import cate.common.util.XT;
import cate.game.play.config.PlayCfgArgs;
import cate.game.play.fighter.Fighter;
import cate.game.play.proce.action.ctx.ActionCtx;
import cate.game.play.skill.passive.PassiveHandler;
import easy.java.struct.ref.DoubleRef;

/**
 * 受到的单次伤害超过最大生命值的40%，有35%概率抵消所有伤害的50%
 */
public class 避险PH extends PassiveHandler {

	private double 生命系数;

	private int 概率;

	private double 减免;

	//生命系数=4000&概率=3500&减免=500
	@Override
	public void parse(String code) {
		PlayCfgArgs args = new PlayCfgArgs(code);
		生命系数 = args.getWDouble("生命系数",0d);
		概率 = args.getInt("概率", 0);
		减免 = args.getWDouble("减免",0d);
	}

	@Override
	public void adjustSkillDamage(ActionCtx action, Fighter actor, int reason, DoubleRef doubleRef) {
		if (doubleRef.v < skill.owner.attr.total().hpCur() * 生命系数) {
			return;
		}
		if (!XT.chance(概率)) {
			return;
		}
		doubleRef.v *= (1 - 减免);
	}
}
